import xml.sax.handler
import xml.sax.xmlreader
import Base

class UserHandler(xml.sax.handler.ContentHandler) :
    def __init__(self) :
        """
        user handler
        """
        self.tag = "unknown"

    def startElement(self, name, attributes) :
        if name == "getMap" :
            self.bottomRight = attributes["bottomRight"]
            self.topLeft = attributes["topLeft"]
        
        if name == "login" :
            self.tag = name;
            self.mail = ""
            self.mail = attributes["mail"]
            self.passw = attributes["passw"] 

        if name == "message" :
            self.tag = name
            self.From = attributes["From"]
            self.To = attributes["To"]
            self.content = attributes["content"]

        if name == "move" :
            self.tag = name
            self.charac_id = attributes["charac_id"]
            self.x = attributes["x"]
            self.y = attributes["y"]

        if name == "onlineUsers" :
            self.tag = name

        if name == "policy-file-request" :
            self.tag = "policy-file-request"
            print "ici, userHandler .. on est dans policy-file-request"
            
        if name == "quit" :
            print "quit"
            self.id = attributes["id"]
            
        if name == "register" :
            self.tag = name
            self.mail = attributes["mail"]
            self.passw = attributes["passw"]
            
        if name == "updateProfile" :
            self.tag = name;
            self.id = attributes["id"]
            self.mail = attributes["mail"]
            self.pwd = attributes["pwd"]
            self.lastName = attributes["lastName"]
            self.firstName = attributes["firstName"]
            self.gender = attributes["gender"]
            self.nick = attributes["nick"]
            #self.age = attributes["age"]
            #self.city = attributes["city"]
            self.country = attributes["country"]
            self.countryIndex = attributes["countryIndex"]
            self.birth = attributes["birth"]
            self.sex = attributes["sex"]
            
        if name == "userDetailsReq" :
            self.tag = name
            self.mail = attributes["mail"]
            
